package com.lx.idgenerator.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lx.idgenerator.mapper.LeafNodeMapper;
import com.lx.idgenerator.model.LeafNode;
import com.lx.idgenerator.service.ILeafNodeService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Service;


/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wcy
 * @version V1.0
 * @contact
 * @date 2024-11-08

 */
@Service
public class LeafNodeServiceImpl extends ServiceImpl<LeafNodeMapper, LeafNode> implements ILeafNodeService {

    /**
     * 根据系统ID和业务tag查询数据
     * @param systemId
     * @param bizTag
     * @return
     */
    @Override
    public LeafNode findBySystemIDAndBizTag(String systemId, String bizTag) {
        QueryWrapper<LeafNode> queryWrapper = getQueryWrapperBySystemIDAndBizTag(systemId, bizTag);
        LeafNode node = this.getOne(queryWrapper);
        return node;
    }

    private QueryWrapper<LeafNode> getQueryWrapperBySystemIDAndBizTag(String systemId, String bizTag){
        QueryWrapper<LeafNode> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(LeafNode::getBizTag, bizTag).eq(LeafNode::getSystemId, systemId)
            .eq(LeafNode::getEnableFlag,true);
        return queryWrapper;
    }


}

